package com.dataStructure.栈;

import com.dataStructure.线性表.list_父类.List;
import com.dataStructure.线性表.数组.ArrayList;

public class Stack_通过聚合ArrayList<E> {

    private final List<E> list = new ArrayList<>();

    public void clear(){
        list.clear();
    }

    public int size() {
        return list.size();
    }

    public boolean isEmpty() {
        return list.isEmpty();
    }

    public void push(E element) {
        list.add(element);
    }

    public E pop() {
        return list.remove(list.size() - 1);
    }

    public E top() {
        return list.get(list.size() - 1);
    }
}
